package com.service.impl;

import com.dao.PostingLikeDao;
import com.entity.PostingLike;
import com.service.PostingLikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 帖子点赞业务实现
 *
 * @author lbb
 * @version 1.0
 * @date 2020.3.3
 */
@Service
public class PostingLikeServiceImpl implements PostingLikeService {
	
	@Autowired
	private PostingLikeDao postingLikeDao;
	
	//点赞
	@Override
	@Transactional
	public Integer addPostingLike(PostingLike postingLike) {
		postingLikeDao.addPostingLike(postingLike);
		return postingLikeDao.getTotal(postingLike.getPostingId());
	}
	//取消点赞
	@Override
	public Integer delPostingLike(PostingLike postingLike) {
		postingLikeDao.delPostingLike(postingLike);
		return postingLikeDao.getTotal(postingLike.getPostingId());
	}
	
	//点赞数量
	@Override
	public Integer getTotal(Integer postingId) {
		return postingLikeDao.getTotal(postingId);
	}
}
